<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
    <%@include file="_head.jsp" %>
    <title>给开发者留言</title>
    <script type="text/javascript">
        function send() {
            var params = {};
            params.content = $("#suggestion_content").val().replace(/\n|\r\n/g,"<br/>");
            if(params.content == null || params.content == undefined || params.content == ''){
                $.toptip('内容不能为空', 'error');
                return;
            }
            $.ajax({
                type: "post",
                url : "${ctx}/suggest/add",
                data : params,
                dataType : "json",
                success: function (re) {
                    if(true==re.success){
                        $.toast("操作成功", function () {
                            window.location = "index";
                        });
                    }else {
                        $.toast("后台错误，请联系管理员", "cancel");
                    }
                },
                error: function (re) {
                    $.toast("网络请求失败，请联系管理员", "cancel");
                }
            });
        }
        function reset() {
            $("#suggestion_content").val("");
        }
        function cancel() {
            window.location = "index";
        }
    </script>
</head>
<body ontouchstart>
    <div class="weui-cells weui-cell">
        <div class="weui-cell__bd">
            <textarea class="weui-textarea" id="suggestion_content" placeholder="请输入文本" rows="18"></textarea>
        </div>
    </div>
    <div style="text-align:center">
        <a href="javascript:;" onclick="send()" class="weui-btn weui-btn_primary weui-btn_medium">发送</a>
        <a href="javascript:;" onclick="reset()" class="weui-btn weui-btn_primary weui-btn_medium">重置</a>
        <a href="javascript:;" onclick="cancel()" class="weui-btn weui-btn_primary weui-btn_medium">取消</a>
    </div>

    <%@include file="_foot.jsp" %>
</body>
</html>
